package internal.test;

import internal.MyAsyncEventBus;
import internal.MySubscribe;

import java.util.concurrent.Executors;
import java.util.concurrent.ThreadPoolExecutor;

/**
 * Created by DJJ on 2019/3/28.
 */
public class MyAsyncBusExample
{

    public static void main(String[] args) throws InterruptedException {
        ThreadPoolExecutor t= (ThreadPoolExecutor) Executors.newFixedThreadPool(4);
        MyAsyncEventBus eventBus = new MyAsyncEventBus(t);
        eventBus.register(new MyAsyncBusExample());
        eventBus.register(new MySimpleListener());
        eventBus.register(new MySimpleListener2());
        eventBus.post("hello");
        eventBus.post(9999);
        eventBus.post(123131, "test-topic");
        eventBus.close();
    }
    @MySubscribe
    public void djj(Integer ix){
        try {
            Thread.sleep(3000);
        } catch (InterruptedException e) {
            e.printStackTrace();
        }
        System.out.println("MyAsyncBusExample---"+ix);
    }
}
